package com.zrh.jsd.service.studydemo.common_thread;

public class TestThreadIntreeupt extends Thread {
    public  static volatile int num = 1;
    @Override
    public void run() {
        try {
            while (num == 1) {
                Thread.sleep(10);
            }
        } catch (InterruptedException e) {
            System.out.println("这里收到异常====" + e);
        } catch (IllegalMonitorStateException e1) {
            System.out.println("接收到IllegalMonitorStateException==" + e1);
        }

        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            System.out.println("这里收到异常-----");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new TestThreadIntreeupt();
        thread.start();
        System.out.println("main==3==="+Thread.currentThread().getState());
        Thread.sleep(10);
        System.out.println("main==2==="+Thread.currentThread().getState());
        thread.interrupt();
        System.out.println("main==1==="+Thread.currentThread().getState());
    }
}
